﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using Extensions;
using CustomProviders;

public partial class Brand : System.Web.UI.Page
{
    int brandId;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!string.IsNullOrEmpty(Request.QueryString["id"]))
        {
            brandId = Request.QueryString["id"].ToInt32();
            using (DAL.EShopDBDataContext db = new DAL.EShopDBDataContext())
            {
                var brand = db.Brands.Single(c => c.BrandId == brandId);
                Title = string.Format(Title, brand.Title);
            }
        }
    }
    protected bool IsAdmin
    {
        get 
        { 
            return Roles.IsUserInRole("Administrator"); 
        }
    }
    protected void ProductList_ItemCommand(object sender, ListViewCommandEventArgs e)
    {

        if (e.CommandName.ToUpper() == "EDITREDIRECT")
        {
            ListViewDataItem lvdi = e.Item as ListViewDataItem;
            if (brandId != 0)
                Response.Redirect(string.Format("Product.aspx?id={0}&editmode=true&index={1}&brandId={2}", e.CommandArgument, lvdi.DataItemIndex + 1, brandId));
        }
    }
    protected void TitleEditButton_Click(object sender, ImageClickEventArgs e)
    {

    }
    protected void DescriptionEditor_Save(object sender, Winthusiasm.HtmlEditor.HtmlEditor.SaveEventArgs e)
    {

    }
}
